package vue;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.Observable;
import java.util.Observer;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import modele.Traitement;
/**
 * 
 * @author Plancq Charlotte, Lanvin Kévin, Darras Raphael
 *
 *
 */
public class AffichageGlobal extends JPanel implements Observer {
	private static final long serialVersionUID = 1L;
	public JPanel haut, bas, gauche, centre;
	@SuppressWarnings("unused")
	private Fenetre f;
	private Traitement t;
	
	public AffichageGlobal(final Fenetre f, Traitement t) {
		t.addObserver(this);
		this.t=t;
		this.f=f;
		setLayout(new BorderLayout(10, 10));
		setBorder(new EmptyBorder(0, 10, 10, 10));
		
		haut = new PanelMenu(this);
		add(haut, BorderLayout.NORTH);
		
		gauche = new PanelCollections(this);
		gauche.setPreferredSize(new Dimension(200, 400));
		add(gauche, BorderLayout.WEST);
		
		centre=new JPanel();
		centre.setBorder(BorderFactory.createTitledBorder(""));
		add(centre, BorderLayout.CENTER);
		
		bas = new PanelFooter(this);
		add(bas, BorderLayout.SOUTH);
		setCentre(new AffichageMenu(this));
	}
	public Traitement getTraitement(){
		return this.t;
	}
	
	public JPanel getCentre() {
		return centre;
	}
	
	public void setCentre(JPanel p) {
		centre.removeAll();
		centre.setVisible(false);
		centre.add(p);
		add(centre, BorderLayout.CENTER);
		invalidate();validate();
		centre.setVisible(true);
	}
	@Override
	public void update(Observable o, Object arg) {
		((PanelCollections)gauche).update();
		this.repaint();
	}
	public PanelCollections getGauche() {
		return (PanelCollections)this.gauche;
	}
	public String getRecherche(){
		return ((PanelMenu)haut).getRecherche();
	}
	public void clearRecherche(){
		((PanelMenu)haut).clearRecherche();
	}
}
